/**
 * @file    wifihack_mod.c
 * @Author  Riccardo Manfrin [namesurname at gmail dot com]
 * @brief   Driver functionalities implemented for the char device.
 */
#include <linux/init.h>
#include <linux/module.h>
#include <linux/sched.h> //current->comm

#include "drv.h"

/**
 * Static parameter to switch major dev number generation from static to
 * dynamic. Brief description of the possible parameter settings is defined
 * through the macro MODULE_PARM_DESC and can be visualized through modinfo app
 * File system generates a file for each declared parameter, whose permissions
 * are defined through the 3rd module_param function argument.
 */
static unsigned int staticAlloc = 0;
module_param(staticAlloc, int, 0);
MODULE_PARM_DESC(staticAlloc, "Magic numbers generation [0 => dynamic, !=0 => static]");

static unsigned int cdevDim = 1000;
module_param(cdevDim, int, 0);
MODULE_PARM_DESC(cdevDim, "Bytesize of the circular buffer [0 => default (1000B)]");

static unsigned int ODoW=0;
module_param(ODoW, int, 0);
MODULE_PARM_DESC(ODoW, "Old Data overWrite when exceeding reading offset [0 => default (NO), !=0 => YES]");

int prova;
EXPORT_SIMBOL(prova);

static int __init wifihack_init(void)
{
    ///KERN_ALERT is a string specifying the priority of the message to print
    ///Note the absence of the comma.
    printk(KERN_INFO "wifihack: Init... done\n");
    ///Function to register the device driver allowed operations
    wh_drv_reg(staticAlloc, cdevDim, ODoW);
    return 0;
}
static void __exit wifihack_exit(void)
{
    printk(KERN_INFO "wifihack: Exit... done\n");
    ///Function to release the device driver 
    wh_drv_unreg();
    return;
}
//Macros to declare the init and exit functions of the module.
module_init(wifihack_init);
module_exit(wifihack_exit);

MODULE_AUTHOR("Riccardo Manfrin");
MODULE_DESCRIPTION("Wifihack module");
//Macro to inform the kernel abouth the licence of the module.
MODULE_LICENSE("GPL v2");
